<?php
class Menu extends CActiveRecord
{
/**
* This is the model class for table "Menu".
*/

/**
* The followings are the available columns in table 'tbl_menu':
* @property integer $id
* @property integer $parent_id
* @property string $title
* @property integer $position
*/

/*public $parentPath;*/

/**
* Returns the static model of the specified AR class.
* @return Menu the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}

/**
* @return string the associated database table name
*/
/*public function tableName()
{
return 'Menu';
}*/

/**
* @return array behaviors.
*/
public function behaviors()
{
return array(
'TreeBehavior' => array(
'class' => 'ext.behaviors.XTreeBehavior',
'treeLabelMethod'=> 'getTreeLabel',
'menuUrlMethod'=> 'getMenuUrl',
),
);
}

	/**
	 * @return array validation rules for model attributes.
	 */
	/*public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id', 'required'),
			array('label', 'length', 'max'=>50),
			array('parent_id, position', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, parent_id, label, position', 'safe', 'on'=>'search'),
		);
	}*/

/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'parent' => array(self::BELONGS_TO, 'Menu', 'parent_id'),
'children' => array(self::HAS_MANY, 'Menu', 'parent_id', 'order' => 'position'),
'childCount' => array(self::STAT, 'Menu', 'parent_id'),
);
}

/**
* @return array customized attribute labels (name=>label)
*/
/*public function attributeLabels()
{
return array(
'id' => Yii::t('ui', 'ID'),
'parent_id' => Yii::t('ui', 'Parent'),
'label' => Yii::t('ui', 'Label'),
'position' => Yii::t('ui', 'Position'),
);
}*/

/**
* @return string tree label
*/
public function getTreeLabel()
{
return $this->label;
}





}

?>